//Emergency Powers in Democratic States: Introducing The DEP Dataset
//Bryan Rooney


use "DEP Analysis Data.dta", clear

global X "pastmids rivalry regchg3 pastcoups polity2 legfralower polconiii lpop ln_gdp cinc"

eststo clear
eststo:  heckprob emergencypow $X , select(changenew=$X demspl* timespl*) cluster(ccode)
eststo:  heckman empowerscore3 $X , select(changenew=$X demspl* timespl*) cluster(ccode)
	estout using "causes_predict.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Emergency Power Provision" "Emergency Power Strength", pattern(1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep($X _cons) ///
		order($X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace \hline Democracy Year Splines & Yes & Yes \\")) ///
		mlabels("(1)" "(2)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace	
eststo clear

eststo clear
eststo: logit emergencypow $X demspl* if changenew==1, robust
eststo: reg empowerscore3 $X demspl* if changenew==1, robust
	estout using "causes_new_docs.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Emergency Power Provision" "Emergency Power Strength", pattern(1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep($X _cons) ///
		order($X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace \hline Democracy Year Splines & Yes & Yes \\")) ///
		mlabels("(1)" "(2)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace	
eststo clear


//Descriptive Only


by ccode: gen l_constitutionyear = constitutionyear[_n-1]
gen con=0
replace con=1 if changenew==1
replace con=1 if l_constitutionyear==.
collapse (sum) con, by(ccode)


tab con

  (sum) con |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         73       64.60       64.60
          2 |         25       22.12       86.73
          3 |         13       11.50       98.23
          4 |          1        0.88       99.12
          5 |          1        0.88      100.00
------------+-----------------------------------
      Total |        113      100.00
